﻿using HHG.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OnLineExam.Data
{
	public partial	class Paper
	{
		public List<Data.PaperInfo> MarkInfo { get {
				var re =new List<Data.PaperInfo>(); 
				var info = this.ProblemInfo;

				//单选:50:3,多选:10:5,判断:0:0,填空:0:0,问答:0:0
				 
				foreach (var item in info.Split(','))
				{
					var tempType = QuestionType.Other;
					var sp = item.Split(':');
					switch (sp[0])
					{
						case "单选":
							tempType= QuestionType.Single;
							break;
						case "多选":
							tempType = QuestionType.Multi;
							break;
						case "判断":
							tempType = QuestionType.Judge;
							break;
						case "填空":
							tempType = QuestionType.Fill;
							break;

						case "问答":
							tempType = QuestionType.Qustion;
							break;
					}
					re.Add(new Data.PaperInfo {
						 Count=sp[1].GetInt(),
						  Mark= sp[2].GetInt(),
						   PaperId=this.PaperID,
						    QuestionType=Paper. GetQuestionType(tempType)
					});
				}

				return re;
			} }

		public static string GetQuestionType(Data.QuestionType questionType)
		{
			return Enum.GetName(typeof(Data.QuestionType), questionType);
		}
		public static QuestionType GetQuestionTypeEnum(string type)
		{
			var array = Enum.GetValues(typeof(Data.QuestionType));
			for (int i = 0; i < array.Length; i++)
			{
				if(array.GetValue(i).GetString()==type)
				return (QuestionType)array.GetValue(i)  ;

				 

			}
			switch (type)
			{
				case "单选题":
					return QuestionType.Single;
					break;
				case "多选题":
					return QuestionType.Multi;
					break;
				case "判断题":
					return QuestionType.Judge;
					break;
				case "填空题":
					return QuestionType.Fill;
					break;
				case "问答题":
					return QuestionType.Qustion;
					break;
				default:
					break;
			}
			return QuestionType.Other; 
		}
	}
	 
	public enum QuestionType {
		Single,Multi,Judge,Fill,Qustion,Other
	}
	 
}
